Imports System.Data.SqlClient

Partial Class cn_company
    Inherits System.Web.UI.Page
    Dim objrd As SqlDataReader = Nothing


    Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Dim sSQL As String = ""
        Dim strErr As String = ""
        Dim objdt As New GetData
        Dim ps As New PreparedStatement(sSQL)
        Dim comId As String
        comId = Request("cid")
        Dim comInfo As String
        comInfo = ""
        Dim productInfo As String
        productInfo = ""

        If comId <> Nothing And comId <> "" Then
            ps.addParameter("cid", comId)
            sSQL = "select *  from  merchant where company_id=@cid and active=1"
            ps.strSql = sSQL
            Dim conn As SqlConnection = objdt.getConn()

            objrd = objdt.dr(ps, strErr, conn, objrd)
            If Not objrd.Read() Then
                objdt.closeConn(conn)
                Exit Sub
            End If
            productInfo = objrd("photo_path").ToString
            cImage.Src = productInfo
            sSQL = "select *  from  merchant_info where company_id=@cid and lang_flag='zh'"
            ps.strSql = sSQL
            objrd = objdt.dr(ps, strErr, conn, objrd)
            If Not objrd.Read() Then
                objdt.closeConn(conn)
                Exit Sub
            End If
            title.InnerHtml += ":" & objrd.Item("company_name")
            companyName.InnerText = objrd.Item("company_name")
            comInfo = objrd("brief").ToString
            cInfo.InnerHtml = comInfo
            sSQL = "select *  from  product_info where company_id=@cid and recommendation=1 and active=1 and lang_flag='zh'"
            ps.strSql = sSQL
            objrd = objdt.dr(ps, strErr, conn, objrd)
            pInfo.InnerHtml = "<table width=""100%"">"
            Dim photoPath As String
            While (objrd.Read())
                Dim i As Integer
                i = 0
                If objrd("photo_path").ToString = "" Then
                    photoPath = "/pic/nopic180.gif"
                Else
                    photoPath = objrd("photo_path").ToString
                End If
                pInfo.InnerHtml += "<tr>"
                pInfo.InnerHtml += "<td width=""25%"" height=""160px"" valign=""top"" align=""center"">"
                pInfo.InnerHtml += "<div><a href=""cn_productdetail.aspx?productId=" & objrd.Item("product_id") & """><img width=""180px"" height=""130px"" src=""" & photoPath & """/></a></div>"
                pInfo.InnerHtml += "<div style=""line-height:25px;"">" & objrd("Product_name").ToString & "</div> </td>"
                For i = 0 To 2
                    If objrd.Read() Then
                        pInfo.InnerHtml += "<td width=""25%"" height=""160px"" valign=""top"" align=""center"">"
                        pInfo.InnerHtml += "<div><a href=""cn_productdetail.aspx?productId=" & objrd.Item("product_id") & """><img width=""180px"" height=""130px"" src=""" & photoPath & """/></a></div>"
                        pInfo.InnerHtml += "<div style=""line-height:25px;"">" & objrd("Product_name").ToString & "</div> </td>"
                    Else
                        Exit For
                    End If
                Next
                pInfo.InnerHtml += "</tr>"
            End While
            objdt.closeConn(conn)

            pInfo.InnerHtml += "</table>"
        Else
            Response.Redirect("cn_index.aspx")
        End If
    End Sub

End Class
